/**
* Author: Samfu
* Time  : 上午12:20:49
* Desc  : 
*/
package com.samfu;

import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.TriggerKey;
import org.quartz.impl.StdSchedulerFactory;

public class MyQuartzQsServer {

	public static void main(String[] args) {
	
		MyQuartzQsServer server = new MyQuartzQsServer();
		try {
			server.startScheduler();
		} catch (SchedulerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	private void startScheduler() throws SchedulerException{
		Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
		JobDetail jobDetail = JobBuilder.newJob(TestJob.class).withIdentity("fkjob").build();
		
		Trigger trigger = TriggerBuilder.newTrigger().withIdentity(TriggerKey.triggerKey("fkTrigger" , "fkTriggerGroup"))
	             .withSchedule(SimpleScheduleBuilder.simpleSchedule()
	                     .withIntervalInSeconds(60)
	                     .repeatForever())
	                 .startNow()
	                 .build();
		scheduler.scheduleJob(jobDetail, trigger);
		scheduler.start();
	}
}
